﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AggregateRoot.Console
{
    public class OrderRepository
    {
        DataContext _db;

        public OrderRepository()
        {
            _db = new DataContext();
        }

        public OrderRepository(DataContext db)
        {
            _db = db;
        }

        public Order GetByOrderId(int orderId)
        {
            return _db.Orders.SingleOrDefault(o => o.OrderID == orderId);
        }

        public void Add(Order order)
        {
            _db.Orders.AddObject(order);
        }

        public void Delete(Order order)
        {
            _db.Orders.DeleteObject(order);
        }

        public void Save()
        {
            _db.SaveChanges();
        }
    }
}
